package com.nimt.hqgl_idea.controller;

import com.nimt.hqgl_idea.entity.User;
import com.nimt.hqgl_idea.param.UserParam;
import com.nimt.hqgl_idea.service.UserService;
import com.nimt.hqgl_idea.vo.PwdVo;
import com.nimt.hqgl_idea.util.ResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/*实现跨域*/
@CrossOrigin
/*表明它是控制层*/
@RestController
/*发送Request请求*/
/*localhost:8080/user*/
@RequestMapping("/user")
public class UserController {

    /*自动装配*/
    @Autowired
    UserService userService;

    /*发送Request请求*/
    @PostMapping("/login")
    public ResponseBody login(User user){
        return userService.login(user);
    }

    @GetMapping("/query")
    public ResponseBody query(UserParam userParam){
        return userService.query(userParam);
    }

    @GetMapping("/selectOne")
    public ResponseBody selectOne(User user){
        return userService.selectOne(user);
    }

    @PutMapping("/password")
    public ResponseBody password(PwdVo pwdVo){
        return userService.updatePwd(pwdVo);
    }

    @PutMapping("/info")
    public ResponseBody updateInfo(User user){
        return userService.updateInfo(user);
    }

    @PostMapping("/add")
    public ResponseBody add(User user){
        return userService.add(user);
    }

    @PostMapping("/del")
    public ResponseBody del(Integer id){
        return userService.delete(id);
    }

}
